#pragma strict
//////////////////////////////////////////////////////
///一直旋转.
//////////////////////////////////////////////////////
var xSpeed:float = 0;
var ySpeed:float = 1;
var zSpeed:float = 0;
/** 开始时间 */
var waitTime:float = 0;
/** 存活时间 */
var lifeTime:float = 10;
/** 消失速度 */
var disappearSpeed:float = 0.01;

var scaleStart:float = 1;
var scaleEnd:float= 1;
var scaleSpeed:float = 0.1;
private var curScale:float;

private var isStart:boolean = false;
private var startTime:float;

function Start(){
	startTime = Time.time;
	transform.localScale = Vector3.one * scaleStart;
	while((Time.time-startTime) <= waitTime){
		yield;
	}
	isStart = true;
	startTime = Time.time;
}

function Update(){
	if(isStart){
		transform.Rotate(Vector3(xSpeed,ySpeed,zSpeed),Space.World);
		if( (Time.time-startTime)>lifeTime){
			Disappear();
		}
		if(curScale < scaleEnd){
			curScale += scaleSpeed;
			transform.localScale += Vector3.one * scaleSpeed;
		}
	}
}

/** 消失 */
function Disappear(){
	var renderer:Renderer = GetComponent.<Renderer>();
	if(renderer && renderer.material.HasProperty("_Color")){
		while(renderer.material.color.a > 0){
			renderer.material.color.a -= disappearSpeed;
			yield;
		}
	}
	Destroy(gameObject);
}